package com.tyk.bookstore.back.system.model.vo;

import com.tyk.bookstore.back.system.model.type.MenuType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
public class MenuListVo {

    @Schema(description = "菜单ID")
    private Long id;

    @Schema(description = "路由名称", nullable = true)
    private String name;

    @Schema(description = "路由路径")
    private String path;

    @Schema(description = "路由组件", nullable = true)
    private String component;

    @Schema(description = "重定向路由地址", nullable = true)
    private String redirect;

    @Schema(description = "菜单标题", nullable = true)
    private String title;

    @Schema(description = "菜单图标", nullable = true)
    private String icon;

    @Schema(description = "菜单类型", type = "number")
    private MenuType type;

    @Schema(description = "路由隐藏行为: false代表展示, true代表隐藏")
    private Boolean hidden;

    @Schema(description = "页签缓存", nullable = true)
    private Boolean keepAlive;

    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    @Schema(description = "子菜单列表", nullable = true)
    private List<MenuListVo> children;

    public void addChild(MenuListVo vo) {
        if (this.children == null) this.children = new ArrayList<>();
        this.children.add(vo);
    }
}
